<html>
<head><meta charset="utf-8"><title>T behind references/pointers · t-compiler/wg-polymorphization · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/index.html">t-compiler/wg-polymorphization</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/T.20behind.20references.2Fpointers.html">T behind references/pointers</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206492516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/T%20behind%20references/pointers/near/206492516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/T.20behind.20references.2Fpointers.html#206492516">(Aug 10 2020 at 18:03)</a>:</h4>
<p>A thought that I don’t want to forget (will write an issue at some point) - polymorphization could be smarter without introducing too much complexity if we treated <code>T</code> as unused if it were behind a reference/pointer that never got dereferenced, right? (and wasn’t used in any other circumstance that would necessitate it marked as used)</p>



<a name="206492701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/T%20behind%20references/pointers/near/206492701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/T.20behind.20references.2Fpointers.html#206492701">(Aug 10 2020 at 18:04)</a>:</h4>
<p>even reborrows would be fine, but <code>T</code> must be marked as used if <code>?Sized</code>, as we don't know the size of the pointer in that case</p>



<a name="206494001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216091-t-compiler/wg-polymorphization/topic/T%20behind%20references/pointers/near/206494001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/216091-t-compiler/wg-polymorphization/topic/T.20behind.20references.2Fpointers.html#206494001">(Aug 10 2020 at 18:17)</a>:</h4>
<p>If a pointer gets dereferenced, there are several cases: the value gets stored in a local (<code>T</code> used because of the local), the value of a local gets assigned to the pointee (<code>T</code> used because of the local), the value of a computation gets assigned to the pointee (<code>T</code> is either not a param, or one of the parts of the computation mentions <code>T</code> in such a way that it is used), a projection is reborrowed (<code>T</code> is unused if <code>Sized</code>) or the pointee is used by a terminator (<code>T</code> is either not a param, or is mentioned some other way that counts as a use) In any case the dereference itself can safely be marked as not using <code>T</code> I think. At most it would use the alignment of <code>T</code> for optimizations.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>